$(function () {

    //置顶按钮
    $(".toTop").on("mouseenter", function () {
        $(this).css("background", "url('./images/mainZhiding.png')")
    }).on("mouseleave", function () {
        $(this).css("background", "url('./images/cartzhiding.png')")
    }).on("click", function () {
        // // console.log($(window).scrollTop("0"))
        // $(window).scrollTop()
        let timerX = setInterval(() => {
            let target = 0;
            let current = $(window).scrollTop()
            let step = (target - current) / 10
            step = step > 0 ? Math.ceil(step) : Math.floor(step)
            $(window).scrollTop(current + step)
            if (target - current == 0) {
                clearInterval(timerX)
            }
        })
    })



    //在线客服
    $(".QQchat").on("click", ".close", function () {
        if ($(".QQchat").css("right") == "-178px") {
            $(".QQchat").animate({
                right: "2px"
            })
        } else {
            $(".QQchat").animate({
                right: "-178px"
            })
        }
    })
})